package com.hikeen.launcherx.functions.usb;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * Author by LY
 * Email 1078410438@qq.com
 * Date on 2022/3/16.
 */
public class UsbBroadcastReceiver extends BroadcastReceiver {

    private static String TAG = "UsbBroadcastReceiver";
    private static OnUsbStateListener mUsbListener;

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "UsbBroadcastReceiver: ");
        switch (intent.getAction()) {
            case Intent.ACTION_MEDIA_MOUNTED:
                mUsbListener.usbOpen();

                break;
            case Intent.ACTION_MEDIA_UNMOUNTED:
            case Intent.ACTION_MEDIA_REMOVED:
                mUsbListener.usbClose();
                break;
            default:
                break;
        }
    }

    public static void setmUsbListener(OnUsbStateListener usbListener) {
        mUsbListener = usbListener;
    }
}
